<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* Author: Jorge Torres
 * Description: Login controller class
 */
class Auth extends CI_Controller{
    
    function __construct(){
        parent::__construct();
    }
    
    public function index($msg = NULL){
        redirect('home');
    }
    
    public function login(){
        // Load the model
        $this->load->model('auth_model');
        // Validate the user can login
        $result = $this->auth_model->login();
        // Now we verify the result
        if(!$result){
            // If user did not validate, then show them login page again
            $msg = '<font color=red>Invalid username and/or password.</font><br />';
            $this->index($msg);
        }else{
        	redirect('home');
        }        
    }
    
    public function signup(){
    	$this->load->model('auth_model');
    	$result = $this->auth_model->signup();
    	if(!$result){
    		$msg = '<div class="alert alert-error">Invalid information</div>';
    		$this->load->library('../controllers/home');
    		$this->home->signup($msg);
    	}else{
    		$msg = '<div class="alert alert-success">Signup Complated</div>';
    		$this->load->library('../controllers/home');
    		$this->home->signup($msg);
    	}
    }
    
    
}
?>